package com.fei.test;

import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Random;

import org.apache.storm.shade.com.google.common.collect.Lists;

import com.alibaba.fastjson.JSONObject;

public class Main {
	public static void main1(String[] args) throws InterruptedException {
		
		Object[] o = new Object[20];
		Random random = new Random();
		for(int i = 0 ; i < 20;i++){
			o[i] = random.nextFloat();
		}
		
		List<Object> newDatas = Arrays.asList(o.clone());
        Collections.sort(newDatas, new Comparator<Object>() {
            @Override
            public int compare(Object o1, Object o2) {
                float f1 = Float.parseFloat(o1.toString());
                float f2 = Float.parseFloat(o2.toString());

                return f1 > f2 ? 1 : f1 == f2 ? 0 : -1;
            }
        });
        
        for(int i = 0 ; i < 20;i++){
        	System.out.print(o[i] + ",");
        }
        
        System.out.println();
        
        for(int i = 0 ; i < 20;i++){
        	System.out.print(newDatas.get(i) + ",");
        }
	}
	
	public static void main(String[] args) {
		String s = "1,2,3";
		
		List<String> list = Lists.newArrayList(s.split(","));
		
		list.add(0,"0");
		System.out.println(list);
		
		String str  = "203";
		System.out.println(str.substring(str.length() - 1 , str.length()));
		
		Map<String,GrayType> m = JSONObject.parseObject("{\"apple\":{\"rate\":\"12-13\",\"ver\":\"\"},\"android\":{\"rate\":\"14-15\",\"ver\":\"\"}}", Map.class);
		
		System.out.println(m.get("android").getRate());
	}
}

class GrayType{
	private String rate;
    private String ver;

    public String getRate() {
        return rate;
    }

    public void setRate(String rate) {
        this.rate = rate;
    }

    public String getVer() {
        return ver;
    }

    public void setVer(String ver) {
        this.ver = ver;
    }
}
